#include <gtest/gtest.h>

#include <fstream>

#include <assimp/postprocess.h>

#include <cad-slicer/slicer.h>
#include <cad-slicer/slicer-parameters.h>
#include <cad-slicer/load.h>
#include <cad-slicer/save.h>


namespace cadslicer
{


TEST(slicer_parameters, save_load)
{
  slicer_parameters param;
  param.step = 543;
  param.post_process = aiProcess_CalcTangentSpace | aiProcess_FlipUVs;

  std::string testfile = "test.slicer-parameters.bin";

  std::ofstream output(testfile);
  ASSERT_TRUE(output.is_open());
  ASSERT_TRUE(save(&output, param));

  std::ifstream input(testfile);
  ASSERT_TRUE(input.is_open());

  slicer_parameters reload;
  ASSERT_TRUE(load(&input, &reload));

  EXPECT_EQ(reload.post_process, param.post_process);
  EXPECT_EQ(reload.step     , param.step     );
}


} // cadslicer
